home *** CD-ROM | disk | FTP | other *** search
- import java.applet.Applet;
- import java.applet.AudioClip;
- import java.awt.Button;
- import java.awt.Choice;
- import java.awt.Color;
- import java.awt.Component;
- import java.awt.Container;
- import java.awt.Font;
- import java.awt.FontMetrics;
- import java.awt.Graphics;
- import java.awt.Image;
- import java.awt.LayoutManager;
- import java.awt.MediaTracker;
- import java.awt.event.ActionEvent;
- import java.awt.event.ActionListener;
- import java.awt.event.MouseEvent;
- import java.awt.event.MouseListener;
- import java.net.MalformedURLException;
- import java.net.URL;
- import java.net.URLEncoder;
- import java.util.EventObject;
-
- public class SoundPlayer extends Applet implements Runnable, ActionListener, MouseListener {
- // $FF: renamed from: wi int
- private int field_0;
- // $FF: renamed from: he int
- private int field_1;
- private Color backCol;
- private int currentSound;
- private Image backImage;
- private String backImageName;
- private Color backColor;
- private AudioClip[] sounds;
- private String[] soundNames;
- private String[] soundFilesNames;
- private Button buttonPlay;
- private Button buttonStop;
- private Button buttonPrev;
- private Button buttonNext;
- private String playLabel;
- private String stopLabel;
- private String prevLabel;
- private String nextLabel;
- private boolean[] isLoaded;
- private Choice list;
- private boolean loaded;
- private Image buffer;
- // $FF: renamed from: b java.awt.Graphics
- private Graphics field_2;
- private Image fond;
- private Thread thread;
- private int pause;
- private boolean isPlaying = false;
- // $FF: renamed from: fm java.awt.FontMetrics
- private FontMetrics field_3;
- private Image title;
- private int titleWidth;
- private int titleHeight;
- private int space;
- // $FF: renamed from: X int
- private int field_4;
- // $FF: renamed from: XX int
- private int field_5;
- private String prefix;
- private int autoPlay;
- private String statusBarText;
-
- public String getAppletInfo() {
- return "Name: SoundPlayer\r\nAuthor: Taiji Software";
- }
-
- public void register() {
- try {
- URL u = new URL("http://www.taijisoftware.com");
- ((Applet)this).getAppletContext().showDocument(u, "_blank");
- } catch (Exception e) {
- System.out.println(e);
- this.stop();
- }
- }
-
- public void init() {
- String codeBase = null;
-
- try {
- codeBase = (new URL(((Applet)this).getCodeBase().toString())).getHost();
- System.out.println("Copyright 1999, 2001 Taiji Software(tm)\nYour domain name is : " + codeBase);
- codeBase = codeBase.toUpperCase();
- } catch (Exception var10) {
- }
-
- if (!((Applet)this).getCodeBase().toString().toUpperCase().startsWith("FILE") || ((Applet)this).getParameter("debug") != null) {
- String regCode = ((Applet)this).getParameter("registration_code");
- if (regCode == null) {
- regCode = ((Applet)this).getParameter("reg_domain");
- if (regCode == null) {
- this.register();
- } else {
- if (regCode.length() == codeBase.length() + 4 && !codeBase.startsWith("WWW.")) {
- codeBase = "WWW." + codeBase;
- } else if (regCode.length() == codeBase.length() - 4 && codeBase.startsWith("WWW.")) {
- codeBase = codeBase.substring(4);
- }
-
- char[] chars = new char[codeBase.length()];
- codeBase.getChars(0, codeBase.length(), chars, 0);
- String key = new String("haricot");
- char[] chars2 = new char[key.length()];
- key.getChars(0, key.length(), chars2, 0);
-
- for(int i = 0; i < codeBase.length(); ++i) {
- int j;
- if (i >= key.length()) {
- j = i - key.length() * (i / key.length());
- } else {
- j = i;
- }
-
- chars[i] += chars2[j];
- chars[i] = (char)(chars[i] - chars[i] / 26 * 26 + 97);
- }
-
- String res = new String(chars);
- if (!res.equalsIgnoreCase(regCode)) {
- this.register();
- }
- }
- } else if (!regCode.equals("settevercsedegnamiaj") && !regCode.equals("8078")) {
- this.register();
- }
- }
-
- this.getParameters();
- ((Container)this).setLayout((LayoutManager)null);
- this.fond = ((Component)this).createImage(this.field_0, this.field_1);
- this.buffer = ((Component)this).createImage(this.field_0, this.field_1);
- this.field_2 = this.buffer.getGraphics();
- if (this.backImageName == null) {
- ((Component)this).setBackground(this.backColor);
- } else {
- this.backImage = ((Applet)this).getImage(((Applet)this).getCodeBase(), this.backImageName);
- MediaTracker tracker = new MediaTracker(this);
- tracker.addImage(this.backImage, 0);
-
- try {
- tracker.waitForAll();
- this.loaded = !tracker.isErrorAny();
- } catch (Exception e) {
- System.err.println(e);
- }
-
- if (!this.loaded) {
- System.out.println("problem while loading background image...");
- this.stop();
- }
- }
-
- ((Component)this).repaint();
- this.buttonPlay = new Button(this.playLabel);
- this.buttonPlay.addActionListener(this);
- ((Container)this).add(this.buttonPlay);
- this.buttonStop = new Button(this.stopLabel);
- this.buttonStop.addActionListener(this);
- ((Container)this).add(this.buttonStop);
- this.buttonNext = new Button(this.nextLabel);
- this.buttonNext.addActionListener(this);
- ((Container)this).add(this.buttonNext);
- this.buttonPrev = new Button(this.prevLabel);
- this.buttonPrev.addActionListener(this);
- ((Container)this).add(this.buttonPrev);
- int maxLength = this.buttonPlay.getPreferredSize().width + this.buttonStop.getPreferredSize().width + this.buttonNext.getPreferredSize().width + this.buttonPrev.getPreferredSize().width;
- int space = (int)((float)(this.field_0 - maxLength) / 7.0F);
- this.list = new Choice();
- this.isLoaded = new boolean[this.soundNames.length];
- this.sounds = new AudioClip[this.soundNames.length];
-
- for(int i = 0; i < this.soundNames.length; ++i) {
- this.list.addItem(this.soundNames[i]);
- this.isLoaded[i] = false;
- }
-
- this.list.select(this.soundNames[0]);
- ((Container)this).add(this.list);
- this.buttonPrev.setBounds(2 * space, this.field_1 - this.list.getPreferredSize().height - this.buttonPrev.getPreferredSize().height - 20, this.buttonPrev.getPreferredSize().width, this.buttonPrev.getPreferredSize().height);
- this.buttonPlay.setBounds(3 * space + this.buttonPrev.getPreferredSize().width, this.field_1 - this.list.getPreferredSize().height - this.buttonPrev.getPreferredSize().height - 20, this.buttonPlay.getPreferredSize().width, this.buttonPlay.getPreferredSize().height);
- this.buttonStop.setBounds(4 * space + this.buttonPrev.getPreferredSize().width + this.buttonPlay.getPreferredSize().width, this.field_1 - this.list.getPreferredSize().height - this.buttonPrev.getPreferredSize().height - 20, this.buttonStop.getPreferredSize().width, this.buttonStop.getPreferredSize().height);
- this.buttonNext.setBounds(5 * space + this.buttonPrev.getPreferredSize().width + this.buttonPlay.getPreferredSize().width + this.buttonStop.getPreferredSize().width, this.field_1 - this.list.getPreferredSize().height - this.buttonPrev.getPreferredSize().height - 20, this.buttonNext.getPreferredSize().width, this.buttonNext.getPreferredSize().height);
- this.list.setBounds((this.field_0 - this.list.getPreferredSize().width) / 2, this.field_1 - this.list.getPreferredSize().height - 10, this.list.getPreferredSize().width, this.list.getPreferredSize().height);
- this.initPaint();
- if (this.autoPlay == 1) {
- this.actionPerformed(new ActionEvent(this.buttonPlay, 1001, "play"));
- }
-
- ((Component)this).repaint();
- }
-
- public void getParameters() {
- this.field_0 = ((Component)this).getSize().width;
- this.field_1 = ((Component)this).getSize().height;
- this.backImageName = ((Applet)this).getParameter("background_image");
- if (this.getColor("background_color") != null) {
- this.backColor = this.getColor("background_color");
- }
-
- String s = ((Applet)this).getParameter("play_label");
- if (s != null) {
- this.playLabel = s;
- }
-
- s = ((Applet)this).getParameter("stop_label");
- if (s != null) {
- this.stopLabel = s;
- }
-
- s = ((Applet)this).getParameter("prev_label");
- if (s != null) {
- this.prevLabel = s;
- }
-
- s = ((Applet)this).getParameter("next_label");
- if (s != null) {
- this.nextLabel = s;
- }
-
- s = ((Applet)this).getParameter("prefix");
- if (s != null) {
- this.prefix = s;
- }
-
- s = ((Applet)this).getParameter("pause");
- if (s != null) {
- this.pause = Integer.parseInt(s);
- }
-
- s = ((Applet)this).getParameter("auto_play");
- if (s != null) {
- this.autoPlay = Integer.parseInt(s);
- }
-
- s = ((Applet)this).getParameter("status_bar_text");
- if (s != null) {
- this.statusBarText = s;
- }
-
- int n;
- for(n = 1; ((Applet)this).getParameter("clip" + Integer.toString(n)) != null; ++n) {
- }
-
- this.soundNames = new String[n - 1];
- this.soundFilesNames = new String[n - 1];
-
- for(int i = 0; i < this.soundNames.length; ++i) {
- this.soundFilesNames[i] = ((Applet)this).getParameter("clip" + Integer.toString(i + 1));
- this.soundNames[i] = ((Applet)this).getParameter("clip_name" + Integer.toString(i + 1));
- if (this.soundNames[i] == null) {
- this.soundNames[i] = this.soundFilesNames[i];
- }
- }
-
- }
-
- private Color getColor(String param) {
- String s = ((Applet)this).getParameter(param);
- if (s != null) {
- if (s.substring(0, 1).equals("#")) {
- s = s.substring(1);
- int i = Integer.parseInt(s, 16);
- return new Color(i);
- } else {
- return null;
- }
- } else {
- return null;
- }
- }
-
- public final void paint(Graphics g) {
- if (this.backImageName == null || this.loaded) {
- this.field_2.drawImage(this.fond, 0, 0, this);
- this.field_2.drawImage(this.title, this.field_4, this.space, this);
- this.field_2.drawImage(this.fond, 0, this.space, 10, this.space + this.titleHeight, 0, this.space, 10, this.space + this.titleHeight, this);
- this.field_2.drawImage(this.fond, this.field_0 - 10, this.space, this.field_0, this.space + this.titleHeight, this.field_0 - 10, this.space, this.field_0, this.space + this.titleHeight, this);
- g.drawImage(this.buffer, 0, 0, this);
- }
- }
-
- public final void update(Graphics g) {
- this.paint(g);
- }
-
- public void setTitle(String titre, boolean isPrefix) {
- if (isPrefix) {
- titre = this.prefix + " " + titre + " " + this.prefix;
- }
-
- try {
- Font f = new Font("TimesRoman", 1, this.titleHeight / 2);
- this.field_2.setFont(f);
- } catch (Exception var6) {
- Font f = this.field_2.getFont();
- this.field_2.setFont(new Font(f.getName(), f.getStyle(), this.titleHeight / 2));
- }
-
- this.field_3 = this.field_2.getFontMetrics();
- this.titleWidth = this.field_3.stringWidth(titre);
- this.title = ((Component)this).createImage(this.titleWidth, this.titleHeight);
- Graphics e = this.title.getGraphics();
- e.setColor(Color.black);
- e.fillRect(0, 0, this.titleWidth, this.titleHeight);
-
- try {
- Font f = new Font("TimesRoman", 1, this.titleHeight / 2);
- e.setFont(f);
- } catch (Exception var5) {
- Font f = this.field_2.getFont();
- e.setFont(new Font(f.getName(), f.getStyle(), this.titleHeight / 2));
- }
-
- e.setColor(Color.white);
- e.drawString(titre, 0, this.field_3.getHeight());
- this.field_4 = (this.field_0 - this.titleWidth) / 2;
- e.dispose();
- }
-
- public void run() {
- Thread.currentThread().setPriority(4);
-
- while(true) {
- this.field_4 -= 5;
- if (this.field_4 < -this.titleWidth) {
- this.field_4 = this.field_0;
- }
-
- ((Component)this).repaint();
-
- try {
- Thread.sleep((long)this.pause);
- } catch (InterruptedException var1) {
- }
- }
- }
-
- public void initPaint() {
- Graphics e = this.fond.getGraphics();
- if (this.backImageName != null) {
- int wiIm = this.backImage.getWidth(this);
- int heIm = this.backImage.getHeight(this);
- int w = this.field_0 / wiIm + 1;
- int h = this.field_1 / heIm + 1;
-
- for(int i = 1; i <= h; ++i) {
- for(int j = 1; j <= w; ++j) {
- e.drawImage(this.backImage, (j - 1) * wiIm, (i - 1) * heIm, this);
- }
- }
- } else {
- e.setColor(this.backColor);
- e.fillRect(0, 0, this.field_0, this.field_1);
- }
-
- e.setColor(Color.black);
- this.space = this.buttonPrev.getLocation().y / 6;
- e.fillRect(10, this.space, this.field_0 - 20, 4 * this.space);
- e.dispose();
- this.titleWidth = this.field_0 - 20;
- this.titleHeight = 4 * this.space;
- }
-
- public void actionPerformed(ActionEvent evt) {
- if (((EventObject)evt).getSource() instanceof Button) {
- Button b = (Button)((EventObject)evt).getSource();
- if (b.getLabel().equals(this.playLabel)) {
- if (this.isPlaying) {
- this.sounds[this.currentSound].stop();
- }
-
- this.currentSound = this.list.getSelectedIndex();
- if (!this.isLoaded[this.currentSound]) {
- this.sounds[this.currentSound] = ((Applet)this).getAudioClip(((Applet)this).getCodeBase(), this.soundFilesNames[this.currentSound]);
- this.isLoaded[this.currentSound] = true;
- }
-
- this.sounds[this.currentSound].play();
- this.setTitle(this.soundNames[this.currentSound], true);
- this.isPlaying = true;
- return;
- }
-
- if (b.getLabel().equals(this.stopLabel)) {
- if (this.isPlaying) {
- this.sounds[this.currentSound].stop();
- }
-
- this.setTitle(" ", false);
- this.isPlaying = false;
- return;
- }
-
- if (b.getLabel().equals(this.nextLabel)) {
- if (this.isPlaying) {
- this.sounds[this.currentSound].stop();
- }
-
- ++this.currentSound;
- if (this.currentSound >= this.soundNames.length) {
- this.currentSound = 0;
- }
-
- this.list.select(this.soundNames[this.currentSound]);
- if (!this.isLoaded[this.currentSound]) {
- this.sounds[this.currentSound] = ((Applet)this).getAudioClip(((Applet)this).getCodeBase(), this.soundFilesNames[this.currentSound]);
- this.isLoaded[this.currentSound] = true;
- }
-
- this.sounds[this.currentSound].play();
- this.setTitle(this.soundNames[this.currentSound], true);
- this.isPlaying = true;
- return;
- }
-
- if (b.getLabel().equals(this.prevLabel)) {
- if (this.isPlaying) {
- this.sounds[this.currentSound].stop();
- }
-
- --this.currentSound;
- if (this.currentSound < 0) {
- this.currentSound = this.soundNames.length - 1;
- }
-
- this.list.select(this.soundNames[this.currentSound]);
- if (!this.isLoaded[this.currentSound]) {
- this.sounds[this.currentSound] = ((Applet)this).getAudioClip(((Applet)this).getCodeBase(), this.soundFilesNames[this.currentSound]);
- this.isLoaded[this.currentSound] = true;
- }
-
- this.sounds[this.currentSound].play();
- this.setTitle(this.soundNames[this.currentSound], true);
- this.isPlaying = true;
- }
- }
-
- }
-
- public void start() {
- if (this.thread == null) {
- this.thread = new Thread(this);
- this.thread.start();
- }
-
- }
-
- public void stop() {
- if (this.thread != null) {
- this.thread = null;
- }
-
- if (this.sounds[this.currentSound] != null) {
- this.sounds[this.currentSound].stop();
- }
-
- }
-
- public URL giveURL(String url) {
- try {
- if (url.toUpperCase().startsWith("HTTP")) {
- return new URL(url);
- } else if (url.toUpperCase().startsWith("FTP")) {
- int p = url.indexOf(":");
- int p2 = url.indexOf(":", p + 1);
- if (p2 != -1) {
- url = url.substring(0, p + 3) + URLEncoder.encode(url.substring(p + 3, url.length()));
- }
-
- p = url.indexOf("%40");
- if (p != -1) {
- url = url.substring(0, p) + "@" + url.substring(p + 3, url.length());
- }
-
- return new URL(url);
- } else {
- return new URL(((Applet)this).getCodeBase(), url);
- }
- } catch (MalformedURLException e) {
- System.out.println(e);
- return null;
- }
- }
-
- public SoundPlayer() {
- this.backColor = Color.white;
- this.pause = 200;
- this.playLabel = "Play";
- this.stopLabel = "Stop";
- this.prevLabel = "Prev";
- this.nextLabel = "Next";
- this.prefix = "";
- ((Component)this).addMouseListener(this);
- }
-
- public void mouseClicked(MouseEvent e) {
- }
-
- public void mouseEntered(MouseEvent e) {
- if (this.statusBarText != null) {
- ((Applet)this).showStatus(this.statusBarText);
- }
-
- }
-
- public void mouseExited(MouseEvent e) {
- }
-
- public void mousePressed(MouseEvent e) {
- }
-
- public void mouseReleased(MouseEvent e) {
- }
- }
-